﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using KinectGame;

namespace MemoGame
{
    public partial class OptionsUI : KinectBaseForm
    {
        public OptionsUI()
        {
            InitializeComponent();
            this.textBox1.Text = Options.Instance.personName;
            if (Game.getInstance().GameSize >= 2 && Game.getInstance().GameSize <= 8)
            {
                this.numericUpDown1.Value = Options.Instance.boardSize;
            }
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            try
            {
                Game.getInstance().Login = ((TextBox)sender).Text;
                Options.Instance.personName = ((TextBox)sender).Text;
                Console.WriteLine("LOGIN: "+Game.getInstance().Login);
            }
            catch (Exception ee)
            {
                Console.WriteLine("Login change failed... "+ee.Message);
            }
        }

        private void numericUpDown1_ValueChanged(object sender, EventArgs e)
        {
            try
            {
                Game.getInstance().GameSize = (int)((NumericUpDown)sender).Value;
                Options.Instance.boardSize = (int)((NumericUpDown)sender).Value; 
                Console.WriteLine("GameSize: " + Game.getInstance().GameSize);
            }
            catch (Exception ee)
            {
                Console.WriteLine("Board size change failed... " + ee.Message);
            }
        }

        private void backButton_Click(object sender, EventArgs e)
        {
            this.gameContext.ApplicationMode(this, new MenuUI(), 0); 
        }

    }
}
